home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8459 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  60 lines

  1. Path: soap.news.pipex.net!pipex!usenet
  2. From: chris.neale@ooh.conqueror.co.uk (Chris Neale)
  3. Newsgroups: comp.lang.c++
  4. Subject: A beginners valiant effort.
  5. Date: Mon, 19 Feb 1996 04:19:09 GMT
  6. Organization: The Extremeties Ltd.
  7. Message-ID: <4g81kr$mrs@soap.news.pipex.net>
  8. Reply-To: chris.neale@ooh.conqueror.co.uk
  9. NNTP-Posting-Host: ak161.du.pipex.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Please, Please! Help! Why doesn't this work - the book says it should,
  13. but the IF statement falls through - like a switch statement. Try it
  14. and see.
  15.  
  16. Thanks, Chris
  17.  
  18. please e-mail responses to neales@dial.pipex.com - Ta.
  19.  
  20.  
  21. #include <iostream.h>
  22. #include <string.h>
  23.  
  24. enum boolean{false, true};
  25.  
  26. class switc_string
  27.     {
  28.     private:
  29.         char string_val_one[16];
  30.         char string_val_two[12];
  31.     public:
  32.         void set_string(char string1[], char string2[])
  33.         {
  34.         strcpy(string_val_one, string1);
  35.         strcpy(string_val_two, string2);
  36.         }
  37.         void get_string(boolean string_index)
  38.         {
  39.         cout << string_index;
  40.         if ( string_index )
  41.             {cout << string_val_one;}
  42.  
  43.         else
  44.             {cout << string_val_two;}
  45.         }
  46.     };
  47.  
  48. void main()
  49.  
  50. {
  51.  
  52. switc_string s1;
  53. s1.set_string("is not flowering","is flowering");
  54. cout << endl;
  55. s1.get_string(1);
  56.  
  57. }
  58.  
  59.  
  60.